package com.kevin.util.tag;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import com.kevin.util.Arith;

public class ArithTag  extends TagSupport{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 134546456L;
	private Double div1;
	private Double div2;
	private int scale;
	
	

	public Double getDiv1() {
		return div1;
	}

	public void setDiv1(Double div1) {
		this.div1 = div1;
	}

	public Double getDiv2() {
		return div2;
	}

	public void setDiv2(Double div2) {
		this.div2 = div2;
	}

	public int getScale() {
		return scale;
	}

	public void setScale(int scale) {
		this.scale = scale;
	}

	@Override
	public int doEndTag() throws JspException {
		// TODO Auto-generated method stub
		
		try {	
			String newStr = "";
			newStr = Arith.div(div1, div2, scale)+"";
			pageContext.getOut().print(newStr);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return SKIP_BODY;
	}

	@Override
	public int doStartTag() throws JspException {
		// TODO Auto-generated method stub
		return EVAL_PAGE;
	}
//	/**
//	 * 去html标签
//	 * @param html
//	 * @return
//	 */
//	private String replaceHtml(String html){   
//        String regEx="<\\/?[^>]+>"; //表示标签   
//        Pattern p=Pattern.compile(regEx);   
//        Matcher m=p.matcher(html);   
//        String s=m.replaceAll("");   
//        return s;   
//    } 

}
